// checkout.js
const totalPriceElement = document.getElementById('total-price');
const payableAmountElement = document.getElementById('payable-amount');

function renderCheckout() {
    let cart = JSON.parse(localStorage.getItem('cart')) || [];
    let totalPrice = 0;
    cart.forEach(product => {
        totalPrice += product.price * product.amount;
    });
    totalPriceElement.textContent = totalPrice;
    payableAmountElement.textContent = totalPrice;
}

renderCheckout();

document.querySelector('.pay').addEventListener('click', function() {
    // 模拟支付成功
    alert('支付成功');
    localStorage.removeItem('cart');
    window.location.href = 'index.html';
});